<?php
namespace Site\Controller;
class AdvertiseController extends CommonController {
    public function index() {
        $data = $this->getPageList(M('Advertise'),array(),'sid desc');
        $this->display();
    }

    public function add() {
        if(IS_POST) {
            D('Advertise','Mysql')->addAdvertise(I('post.'));
            $this->success('广告添加成功','/Advertise');
        }
        $this->display();
    }

    public function update() {
        if(IS_POST) {
            D('Advertise','Mysql')->updateAdvertise(I('post.'));
            $this->success('广告修改成功','/Advertise');
        }else {
            $id = I('get.id');
            verify($id,'isID','非法广告ID');

            $advertiseInfo = M('Advertise')->find($id);
            verify($advertiseInfo,'notEmpty','广告不存在');

            $this->assign('advertiseInfo',$advertiseInfo);
            $this->display();
        }
    }
}
?>

